<script setup>
import { storeToRefs } from 'pinia'
import { useRouter } from 'vue-router'
// import useCounterStore from '../store/counter'
// import useUserStore from '../store/user'
import userStore from '../store/index'
const { counter, user } = userStore()
const router = useRouter()

// const counter = useCounterStore() //获取到仓库
// const user = useUserStore()

const { count, double } = storeToRefs(counter) // 仓库数据变成响应式数据
</script>

<template>
  <div>登录组件 - {{ count }} - {{ double }}</div>
  <button @click="router.push('/Home')">去首页</button>
  <button @click="counter.addOne">+1</button>
  <button @click="counter.addOneAsync">一秒后+1</button>
  <hr />
  <div>姓名:{{ user.name }}- 年龄:{{ user.age }}- 乘倍{{ user.doubleAge }}</div>
  <button @click="user.changeName">改名字</button>
  <button @click="user.addAgeAsync">1秒后加1岁</button>
  <hr />
</template>
